package com.hcrazy.manchester.app.jdbc;

import java.util.ArrayList;
import java.util.List;

import com.hcrazy.manchester.app.pojo.PageModel;
import com.hcrazy.manchester.app.pojo.UserInfo;

public class UserInfoDAO extends BaseDAO<UserInfo>{

	
	public PageModel getUserInfosByCityId(PageModel model,int cityId) throws Exception{
		String sql = "select a.*,b.username,c.cityName,d.provinceName " +
				"from him_user_info a,him_user b,him_town_city c,him_town_province d" +
				" where a.userId = b.userId and a.cityId = c.cityId and c.provinceId = d.provinceId";
		StringBuilder querySQL = new StringBuilder("select f.* from ("+sql+") as f ");
		StringBuilder countSQL = new StringBuilder("select count(*) from ("+sql+") as f");
		StringBuilder whereSQL = new StringBuilder(" where cityId = ? ");
		
		List<Object> paramList = new ArrayList<Object>();
		paramList.add(cityId);
		
		return this.getPageModel(model, querySQL, countSQL, whereSQL, paramList, UserInfo.class);
	}
	
	
}
